package com.scheduledtest.demo.config;

import com.alibaba.fastjson.JSON;
import com.scheduledtest.demo.constant.ScheduledStatus;
import com.scheduledtest.demo.impl.ScheduledTaskServiceImpl;
import com.scheduledtest.demo.model.CostBaseScheduledConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.xml.ws.Action;

@Slf4j
@Component
public class ScheduledTaskRunner implements ApplicationRunner {
    @Autowired
    private ScheduledTaskServiceImpl scheduledTaskService;

    @Override
    public void run(ApplicationArguments args) throws Exception {

//        scheduledTaskService.initAllTask();
//
//        CostBaseScheduledConfig costBaseScheduledConfig = new CostBaseScheduledConfig();
//        costBaseScheduledConfig.setId("11");
//        costBaseScheduledConfig.setScheduledCode("ScheduledTaskJobImpl");
//        costBaseScheduledConfig.setScheduledName("编码1");
//        costBaseScheduledConfig.setCronStr("0/2 * * * * ?");
//
//
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                try {
//                    Thread.sleep(3 * 60 * 1000);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//                scheduledTaskService.restart(costBaseScheduledConfig.getScheduledCode(), costBaseScheduledConfig);
//            }
//        }).start();
    }
}
